package com.example.demo.vo;

import org.springframework.http.HttpStatus;

import java.io.Serializable;

/**
 * 通用返回结果集
 */
public class ResultData implements Serializable {

    private static final long serialVersionUID = 9211889136173018364L;

    //状态码
    private Integer code;
    //消息
    private String msg;
    //数据
    private Object data;

    public ResultData(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResultData() {
    }
    public Integer getCode() {
        return code;
    }
    public void setCode(Integer code) {
        this.code = code;
    }
    public String getMsg() {
        return msg;
    }
    public void setMsg(String msg) {
        this.msg = msg;
    }
    public Object getData() {
        return data;
    }
    public void setData(Object data) {
        this.data = data;
    }



    public static ResultData success(Object data){
        return new ResultData(HttpStatus.OK.value(),"请求成功",data);
    }

    public static ResultData success(){
        return new ResultData(HttpStatus.OK.value(),"请求成功",null);
    }

    public static ResultData error(String msg){
        return new ResultData(HttpStatus.INTERNAL_SERVER_ERROR.value(),msg,null);
    }
}
